import easyAxios from '@/utils/request'
import request from "@/utils/request";

let key = '9b9ccf1ea6aee93829b36234c9980a86';

function userList(username) {
    return easyAxios({
        url: '/springboot/user/list',
        method: 'post',
        data: {
            username: username
        }
    })
}

function getGPS(city, location, name) {
    return easyAxios({
        method: 'get',
        url: 'https://restapi.amap.com/v3/geocode/geo?key=' + key + '&city=' + city + '&address=' + location + name
    })
}

function getAddress(longitude, latitude){
  return request({
    method: 'get',
    url: '/api/getAddress?longitude=' + longitude + '&latitude=' + latitude
  })
}

function getMapImage(longitude, latitude) {
    return easyAxios({
        method: 'get',
        url: 'https://restapi.amap.com/v3/staticmap?key=' + key + '&markers=mid,0xFF0000,A:' + longitude + ',' + latitude + '&zoom=14&scale=2',
    })
}

function Converter(source, longitude, latitude) {
    return easyAxios({
        method: 'get',
        url: 'https://restapi.amap.com/v3/assistant/coordinate/convert?key=' + key + '&coordsys=' + source + '&locations=' + longitude + ',' + latitude,
    })
}

export {userList, getGPS, getAddress, getMapImage, Converter}
